import LocalStorage from './local-storage';

const LOGIN_PAGE_URL = '/html/home/weixin-index.html?logintype=shangcheng';


function check() {
  // 防止出现无限授权跳转 先把这个给注释了

  // if (!LocalStorage.getToken() && !window.location.href.includes('token=')) {
  //   jumpToLoginPage();
  // }
}

function jumpToLoginPage() {
  window.location.href = LOGIN_PAGE_URL;
}

function clearTokenQuery() {
  const href = window.location.href;
  if (href.includes('token=')) {
    window.location.href = href.replace(/\?token=(.)*#/, '#');
  }
}

const TokenCheck = {
  check,
  jumpToLoginPage,
  clearTokenQuery
}

export default TokenCheck;
